const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}

module.exports = {
  formatTime
}

// 设置全局变量
function setGlobalData(context) {
  // 获取小程序实例
  const app = getApp();
  // 获取全局变量
  const globalUrl = app.globalData.globalUrl;
  const islogin = app.globalData.islogin;
  console.log(globalUrl)
  // 更新页面数据
  context.setData({
    globalUrl: globalUrl
  });
}

module.exports = {
  setGlobalData: setGlobalData
}
